import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:xindong/common/xindong_sezhi.dart';

class XinDongNumberTextField extends StatelessWidget {
  final TextEditingController? controller; // 控制器
  final List<TextInputFormatter>? inputFormatters; //规则
  final String? hintText; // 默认
  final TextInputType? keyboardType; // 键盘
  final Widget? prefixIcon; // 左侧组件
  final Widget? suffixIcon; // 右侧Icon
  final TextStyle? style;
  final FocusNode? focusNode;
  final Function(String text)? onChanged;

  const XinDongNumberTextField(
      {Key? key,
      this.controller,
      this.inputFormatters,
      this.hintText,
      this.keyboardType,
      this.prefixIcon,
      this.suffixIcon,
      this.onChanged,
      this.style,
      this.focusNode})
      : super(key: key);

  @override
  Widget build(BuildContext context) {
    return TextField(
      controller: controller,
      inputFormatters: inputFormatters,
      keyboardType: keyboardType,
      maxLines: 1,
      focusNode: focusNode,
      onChanged: onChanged,
      style: style ?? const TextStyle(fontSize: 20, color: DZColors.titleColor, height: 1.3),
      decoration: InputDecoration(
        prefixIcon: prefixIcon,
        suffixIcon: suffixIcon,
        fillColor: DZColors.white50,
        filled: true,
        hintText: hintText,
        hintStyle: const TextStyle(fontSize: 16, color: DZColors.placeholderColor, height: 1.2),
        // 设置这个之后，居中
        contentPadding: const EdgeInsets.fromLTRB(20, 8, 20, 8),
        border: const OutlineInputBorder(
          borderSide: BorderSide.none,
          borderRadius: BorderRadius.all(Radius.circular(30)),
        ),
        // enabledBorder: OutlineInputBorder(
        //   borderSide: BorderSide(color: DZColors.hexStringColor('#CCCCCC'), width: 1.0),
        //   borderRadius: BorderRadius.all(Radius.circular(26)),
        // ),
        // focusedBorder: const OutlineInputBorder(
        //   borderSide: BorderSide(color: DZColors.mainColor, width: 1.0),
        //   borderRadius: BorderRadius.all(Radius.circular(26)),
        // ),
      ),
    );
  }
}
